﻿<template>
<div>
  <vue-form :state="formstate" ref="form" v-show="bankBox">
    <validate tag="div" class="weui-cell_item">
      <div class="weui-cells__title"><span class="err">*</span>账户类型</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" @focus.stop.prevent="handleChangeBankType" v-model="bank_account_type_name" readonly type="text" required name="bank_account_type_name" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_account_type_name" show="$touched">
        <div slot="required" class="err">账户类型必须选择~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item">
      <div class="weui-cells__title"><span class="err">*</span>负责人类型</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" v-model="leader_type_name" @focus.stop.prevent="handleChangeLeaderType" readonly type="text" required name="leader_type" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="leader_type" show="$touched">
        <div slot="required" class="err">负责人类型必须选择~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item">
      <div class="weui-cells__title"><span class="err">*</span>户名</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" v-model="model.bank_account_name" type="text" required name="bank_account_name" placeholder="请输入户名"/>
        </div>
      </div>
      <field-messages name="bank_account_name" show="$touched">
        <div slot="required" class="err">户名必须填写~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item">
      <div class="weui-cells__title"><span class="err">*</span>银行卡号</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" v-model="model.bank_account_no" type="text" required name="bank_account_no" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_account_no" show="$touched">
        <div slot="required" class="err">银行卡号必须填写哦~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item">
      <div class="weui-cells__title"><span class="err">*</span>开户行</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" readonly @focus.stop.prevent="bank=true;options=[];" v-model="bank_name" type="text" required name="bank_name" placeholder="请输入开户行名称查询"/>
        </div>
      </div>
      <field-messages name="bank_name" show="$touched">
        <div slot="required" class="err">开户行必须填写~</div>
        <div slot="validatorBankName" class="err">开户行只能填写中文哦~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item">
      <div class="weui-cells__title"><span class="err">*</span>开户行支行</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" @focus.stop.prevent="dialog = true;options=[];" readonly v-model="bank_branch_name" type="text" required name="bank_branch_code" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_branch_code" show="$touched">
        <div slot="required" class="err">开户行支行必须填写~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item">
      <div class="weui-cells__title"><span class="err">*</span>开户行地址</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" readonly @focus.stop.prevent="handleSelectAddress" v-model="bank_address_name" type="text" required name="bank_address" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_address" show="$touched">
        <div slot="required" class="err">开户行地址必须选择~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item" :custom="{ 'validatorPhone': validatorPhone }">
      <div class="weui-cells__title"><span class="err">*</span>预留手机号</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" v-model="model.bank_pre_mobile" maxlength="11" type="text" required name="bank_pre_mobile" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_pre_mobile" show="$touched">
        <div slot="required" class="err">预留手机号必须填写~</div>
        <div slot="validatorPhone" class="err">手机号格式错误~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item" v-if="model.bank_account_type === 200">
      <div class="weui-cells__title"><span class="err">*</span>证件类型</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" v-model="bank_id_card_name" @focus.stop.prevent="handleChangeCardType" readonly type="text" required name="bank_id_card_type" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_id_card_type" show="$touched">
        <div slot="required" class="err">证件类型必须选择~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item" :custom="{ 'validbankard': validbankard }"  v-if="model.bank_account_type === 200">
      <div class="weui-cells__title"><span class="err">*</span>证件编号</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" v-model="model.bank_id_card_no" type="text" required name="bank_id_card_no" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_id_card_no" show="$touched">
        <div slot="required" class="err">证件编号必须填写~</div>
        <div slot="validbankard" class="err">证件编号格式错误~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item" v-if="model.bank_account_type === 200">
      <div class="weui-cells__title"><span class="err">*</span>证件地址</div>
      <div class="weui-cell">
        <div class="weui-cell__bd">
          <input class="weui-input" v-model="model.bank_id_card_addr" type="text" required name="bank_id_card_addr" placeholder="请选择"/>
        </div>
      </div>
      <field-messages name="bank_id_card_addr" show="$touched">
        <div slot="required" class="err">证件地址必须填写~</div>
      </field-messages>
    </validate>
    <validate tag="div" class="weui-cell_item" v-if="model.bank_account_type === 200">
      <div class="weui-cells__title">证件到期时间</div>
        <div class="weui-cell" style="width: 65%;display: inline-flex;vertical-align:top;">
            <div class="weui-cell__bd">
              <input readonly @focus.stop.prevent="handleDateSelectEnd" class="weui-input" required v-model="model.bank_id_card_expire" name="bank_id_card_expire" type="text" placeholder="请选择"/>
            </div>
        </div>
        <button @touchstart.stop.prevent="model.bank_id_card_expire='9999-99-99'" class="time_btn fr">永久</button>
        <field-messages name="bank_id_card_expire" show="$touched">
          <div slot="required" class="err">证件到期时间必须填写~</div>
        </field-messages>
    </validate>
    <div class="weui-cells weui-cells_form" id="uploader">
      <div class="weui-cell">
          <div class="weui-cell__bd">
            <div class="weui-uploader">
              <div class="weui-uploader__hd">
                <div class="weui-uploader__title">证件照片</div>
              </div>
              <div class="weui-uploader__bd">
                <div class="weui-uploader_box" v-if="model.bank_account_type === 200">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.bank_card" :src="model.bank_card" alt="">
                    <input id="uploaderInput" ref="bank_card" @change="handleUploadBankCard" readonly class="weui-uploader__input" type="file" accept="image/*" multiple="" />
                  </div>
                  <p><span class="err">*</span>银行卡正面</p>
                </div>
                <div class="weui-uploader_box" v-if="model.bank_account_type === 100">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.bank_permit" :src="model.bank_permit" alt="">
                    <input id="uploaderInput" readonly @change="handleUploadBankPermit" ref="bank_permit" class="weui-uploader__input" type="file" accept="image/*" multiple="" />
                  </div>
                  <p><span class="err">*</span>开户许可证</p>
                </div>
                <div class="weui-uploader_box" v-if="model.leader_type === 0">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.leader_id_1" :src="model.leader_id_1" alt="">
                    <input id="uploaderInput" ref="leader_id_1" readonly @change="handleUploadLeader1" class="weui-uploader__input" type="file" accept="image/*" multiple="" />
                  </div>
                  <p><span class="err">*</span>身份证正面</p>
                </div>
                <div class="weui-uploader_box" v-if="model.leader_type === 0">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.leader_id_2" :src="model.leader_id_2" alt="">
                    <input id="uploaderInput" ref="leader_id_2" readonly @change="handleUploadLeader2" class="weui-uploader__input" type="file" accept="image/*" multiple="" />
                  </div>
                  <p><span class="err">*</span>身份证反面</p>
                </div>
                <div class="weui-uploader_box" v-if="model.leader_type === 0">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.leader_id_3" :src="model.leader_id_3" alt="">
                    <input id="uploaderInput" ref="leader_id_3" readonly @change="handleUploadLeader3" class="weui-uploader__input" type="file" accept="image/*" multiple="" />
                  </div>
                  <p><span class="err" v-if="merchant_type === 300">*</span>手持身份证</p>
                </div>
                <div class="weui-uploader_box" v-if="model.bank_account_type === 200 && model.leader_type === 1">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.bank_head" :src="model.bank_head" alt="">
                    <input id="uploaderInput" ref="bank_head" readonly @change="handleUploadBankHead" class="weui-uploader__input" type="file" accept="image/*" multiple="" />
                  </div>
                  <p>手持银行卡正面</p>
                </div>
              </div>
            </div>
          </div>
      </div>
    </div>
    <div class="pb20 pt40">
      <button class="weui-btn weui-btn_primary" @touchstart.stop.prevent="handleClickSubmit">提交审核</button>
    </div>
		<div class="dialog" v-show="dialog">
      <div class="weui-search-bar" id="searchBar">
        <form class="weui-search-bar__form" @submit="handleSearchSubBankName">
            <div class="weui-search-bar__box">
                <i class="weui-icon-search"></i>
                <input type="search" class="weui-search-bar__input" minlength="2" placeholder="搜索" v-model="search_text">
                <a href="javascript:" class="weui-icon-clear" @touchstart.stop.prevent="search_text=''"></a>
            </div>
            <label class="weui-search-bar__label">
                <i class="weui-icon-search"></i>
                <span>搜索</span>
            </label>
        </form>
        <a href="javascript:" class="weui-search-bar__cancel-btn" @touchstart.stop.prevent="search_text='';dialog=false">取消</a>
      </div>
        <div ref="scrollView" class="weui-cells weui-cells_access search_show"  @click="() => {dialog = false}">
          <div>
            <div class="weui-cell" v-for="item in options" :key="item.value" @click="handleSubBankCallBack(item)">
                <div class="weui-cell__bd weui-cell_primary">
                    <p>{{ item.label }}</p>
                </div>
            </div>
          </div>
        </div>
      <div class="showing" v-if="options.length === 0" @touchstart.stop.prevent="dialog=false;options=[];search_text=''"></div>
    </div>
		<div class="dialog" v-show="bank">
      <div class="weui-search-bar" id="searchBar">
        <form class="weui-search-bar__form" @submit="handleSearchBankName">
            <div class="weui-search-bar__box">
                <i class="weui-icon-search"></i>
                <input type="search" class="weui-search-bar__input" minlength="2" placeholder="搜索" v-model="search_text">
                <a href="javascript:" class="weui-icon-clear" @touchstart.stop.prevent="search_text=''"></a>
            </div>
            <label class="weui-search-bar__label">
                <i class="weui-icon-search"></i>
                <span>搜索</span>
            </label>
        </form>
        <a href="javascript:" class="weui-search-bar__cancel-btn" @touchstart.stop.prevent="search_text='';bank=false">取消</a>
      </div>
      <div ref="scrollView2" class="weui-cells weui-cells_access search_show"  @click="() => {bank = false}">
        <div>
          <div class="weui-cell" v-for="item in options" :key="item.value" @click="handleBankCallBack(item)">
              <div class="weui-cell__bd weui-cell_primary">
                  <p>{{ item.label }}</p>
              </div>
          </div>
        </div>
      </div>
      <div class="showing" v-if="options.length === 0" @touchstart.stop.prevent="bank=false;options=[];search_text=''"></div>
    </div>
  </vue-form>
  <div class="show" v-show="!bankBox">
    <div class="weui-flex">账户类型：<span>{{ bank_account_type_name }}</span></div>
    <div class="weui-flex">负责人类型：<span>{{ leader_type_name }}</span></div>
    <div class="weui-flex">户名：<span>{{ model.bank_account_name }}</span></div>
    <div class="weui-flex">银行卡号：<span>{{ model.bank_account_no }}</span></div>
    <div class="weui-flex">开户行：<span>{{ bank_name }}</span></div>
    <div class="weui-flex">开户支行：<span>{{ bank_branch_name }}</span></div>
    <div class="weui-flex">开户地址：<span>{{ bank_address_name }}</span></div>
    <div class="weui-flex">预留手机号：<span>{{ model.bank_pre_mobile }}</span></div>
    <div class="weui-flex" v-if="model.bank_account_type === 200">证件类型：<span>{{ model.bank_id_card_type === 1 ? '身份证' : '' }}</span></div>
    <div class="weui-flex" v-if="model.bank_account_type === 200">证件编号：<span>{{ model.bank_id_card_no }}</span></div>
    <div class="weui-flex" v-if="model.bank_account_type === 200">证件地址：<span>{{ model.bank_id_card_addr }}</span></div>
    <div class="weui-flex" v-if="model.bank_account_type === 200">证件到期日：<span>{{ model.bank_id_card_expire }}</span></div>
    <div class="weui-cells weui-cells_form" id="uploader">
      <div class="weui-cell">
          <div class="weui-cell__bd">
            <div class="weui-uploader">
              <div class="weui-uploader__hd">
                <div class="weui-uploader__title">证件照片</div>
              </div>
              <div class="weui-uploader__bd">
                <div class="weui-uploader_box" v-if="model.bank_account_type === 200">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.bank_card" :src="model.bank_card" alt="">
                  </div>
                  <p><span class="err">*</span>银行卡正面</p>
                </div>
                <div class="weui-uploader_box" v-if="model.bank_account_type === 100">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.bank_permit" :src="model.bank_permit" alt="">
                  </div>
                  <p><span class="err">*</span>开户许可证</p>
                </div>
                <div class="weui-uploader_box" v-if="model.leader_type === 0">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.leader_id_1" :src="model.leader_id_1" alt="">
                  </div>
                  <p><span class="err">*</span>身份证正面</p>
                </div>
                <div class="weui-uploader_box" v-if="model.leader_type === 0">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.leader_id_2" :src="model.leader_id_2" alt="">
                  </div>
                  <p><span class="err">*</span>身份证反面</p>
                </div>
                <div class="weui-uploader_box" v-if="model.leader_type === 0">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.leader_id_3" :src="model.leader_id_3" alt="">
                  </div>
                  <p><span class="err" v-if="merchant_type === 300">*</span>手持身份证</p>
                </div>
                <div class="weui-uploader_box" v-if="model.bank_account_type === 200 && model.leader_type === 1">
                  <div class="weui-uploader__input-box">
                    <img v-if="model.bank_head" :src="model.bank_head" alt="">
                  </div>
                  <p>手持银行卡正面</p>
                </div>
              </div>
            </div>
          </div>
      </div>
    </div>
    <div class="pb20 pt40">
      <button class="weui-btn weui-btn_primary" @touchstart.stop.prevent="bankBox=!bankBox">编辑资料</button>
    </div>
  </div>
</div>
  
</template>

<script>
  import BScroll from 'better-scroll'
  import { validatePhone, validChinese, validateIdentity } from '@/utils/validate'
  import { areaAddress, remoteMethodQuery, GetSearchBankList, merchantBankUpdate } from '@/api/index'
  import { address } from '@/utils/address'
  import { uploader } from '@/utils/uploader'
  import { GetMerchantInfo } from '@/api/salesman'
  import { getAgent, getToken, getId } from '@/utils/auth'

  export default {
    name: 'bank',
    data() {
      return {
        option: [],
        types: [],
        cards: [
          { value: 1, label: '身份证' }
        ],
        options: [],
        address: [],
        bank_account_type_name: '',
        leader_type_name: '',
        bank_id_card_name: '',
        bank_branch_name: '',
        search_text: '',
        bank_name: '', // 开户行
        bank_address_name: '',
        merchant_type: '',
        formstate: {},
        salesman: {},
        iscroll: null,
        iscroll2: null,
        dialog: false,
        bank: false,
        bankBox: false,
        show: false,
        model: {
          bank_account_name: '', // 银行户名
          leader_type: null, // 负责人类型
          bank_account_no: '', // 银行卡号
          leader_id_1: '',
          bank_code: '',
          leader_id_2: '',
          leader_id_3: '',
          bank_certi_inhand: '', // 非法人账户授权书合照（照片）
          bank_branch_code: '', // 对公支行
          bank_account_type: '', // 账户类型
          bank_address: [], // 开户行地址
          bank_pre_mobile: '', // 银行预留手机号
          bank_permit: '', // 开户许可证（照片）
          bank_certi: '', // 非法人账户授权书（照片）
          bank_head: '', // 银行卡正面照
          bank_card: '', // 银行卡面 （照片）
          bank_id_card_type: '', // 对私必传 开户人证件类型
          bank_id_card_no: '', // 对私必传开户人身份证号
          bank_id_card_addr: '', // 对私必传开户人地址
          bank_id_card_expire: ''
        }
      }
    },
    methods: {
      validatorPhone(v) {
        if(validatePhone(v)) {
          return true
        }else {
          return false
        } 
      },
      validbankard(v) {
        if (validateIdentity(v)) {
          return true
        } else {
          return false
        }
      },
      handleChangeBankType() {
        const _this = this
        this.$weui.picker(_this.option, {
          onChange(res) {
            _this.model.bank_account_type = res[0].value
            _this.bank_account_type_name = res[0].label
          }
        })
      },
      handleChangeLeaderType() {
        const _this = this
        this.$weui.picker(_this.types, {
          onChange(res) {
            _this.model.leader_type = res[0].value
            _this.leader_type_name = res[0].label
            _this.model.bank_card = ''
            _this.model.bank_permit = ''
            _this.model.leader_id_3 = ''
            _this.model.leader_id_2 = ''
            _this.model.leader_id_1 = ''
            _this.model.bank_certi = ''
            _this.model.bank_certi_inhand = ''
            _this.model.bank_card_inhand = ''
          }
        })
      },
      handleChangeCardType() {
        const _this = this
        this.$weui.picker(_this.cards, {
          onChange(res) {
            _this.model.bank_id_card_type = res[0].value
            _this.bank_id_card_name = res[0].label
          }
        })
      },
      handleSelectAddress() {
        address(this.address).then(res => {
          this.model.bank_address = res.value
          this.bank_address_name = res.label
        }).catch(err => {
          this.$weui.alert(err)
        })
      },
      handleSubBankCallBack(item) {
        this.model.bank_branch_code = item.value
        this.bank_branch_name = item.label
        this.dialog = false
        this.search_text = ''
        this.options = []
      },
      handleSearchSubBankName(e) {
        e.preventDefault()
        this.$loading(true, '查询中')
        remoteMethodQuery(this.search_text).then(res => {
          if (res.data.errorCode === 0) {
            this.$loading(false)
            this.options = res.data.result
            if (res.data.result.length === 0) {
              this.$weui.alert('没找到该数据')
            }
          } else {
            this.$loading(false)
            this.$weui.alert(res.data.errorMsg)
          }
        })
      },
      handleSearchBankName(e) {
        e.preventDefault()
        this.$loading(true, '查询中')
        GetSearchBankList(this.search_text).then(res => {
          if (res.data.errorCode === 0) {
            this.$loading(false)
            this.options = res.data.result
            if (res.data.result.length === 0) {
              this.$weui.alert('没找到该数据')
            }
          } else {
            this.$loading(false)
            this.$weui.alert(res.data.errorMsg)
          }
        })
      },
      handleBankCallBack(item) {
        this.model.bank_code = item.value
        this.bank_name = item.label
        this.bank = false
        this.search_text = ''
        this.options = []
      },
      handleUploadBankCard() {
        uploader(this, this.$refs.bank_card.files).then(res => {
          this.model.bank_card = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      handleUploadBankPermit() {
        uploader(this, this.$refs.bank_permit.files).then(res => {
          this.model.bank_permit = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      handleUploadLeader1() {
        uploader(this, this.$refs.leader_id_1.files).then(res => {
          this.model.leader_id_1 = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      handleUploadLeader2() {
        uploader(this, this.$refs.leader_id_2.files).then(res => {
          this.model.leader_id_2 = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      handleUploadLeader3() {
        uploader(this, this.$refs.leader_id_3.files).then(res => {
          this.model.leader_id_3 = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      hanleUploadBankCerti() {
        uploader(this, this.$refs.bank_certi.files).then(res => {
          this.model.bank_certi = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      handleUploadSuccbankCardInhand() {
        uploader(this, this.$refs.bank_certi_inhand.files).then(res => {
          this.model.bank_certi_inhand = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      handleUploadBankHead() {
        uploader(this, this.$refs.bank_head.files).then(res => {
          this.model.bank_head = res
          this.show = false
        }).catch(err => {
          this.show = false
          this.$weui.alert(err)
        })
      },
      handleClickSubmit() {
       if(this.formstate.$invalid) {
         this.$weui.alert('请补全资料')
         return false
       } else {
         this.$loading(true, '正在提交')
          merchantBankUpdate(this.$route.query.merchant_num, getAgent(), getId(), getToken(), this.model).then(res => {
            if (res.data.errorCode === 0) {
              this.$loading(false)
              this.$toast.success('提交成功')
              this.bankBox = false
            } else {
              this.$loading(false)
              this.$weui.alert(res.data.errorMsg)
              return false
            }
          })
       }
      },
      handleDateSelectEnd() {
        const _this = this
        const Now = new Date()
        const end = Now.getFullYear() + 100
       this.$weui.datePicker({
          start: new Date(),
          end,
          onChange(res) {
            const value = res[0].value + '-' + res[1].value + '-' + res[2].value
            _this.model.bank_id_card_expire = value
          }
        })
      }
    },
    watch: {
      dialog(v) {
        if(v) {
          this.$weui.searchBar('#searchBar')
        }
      },
      bank(v) {
        if(v) {
         this.$weui.searchBar('#searchBar')
        }
      },
      bank_account_type_name() {
        if (this.model.bank_account_type == 200 && this.merchant_type == 300) {
          this.types = [{ value: 1, label: '法人' }]
        } else if (this.model.bank_account_type == 100) {
          this.types = [{ value: 1, label: '法人' }]
        } else {
          this.types = [{ value: 1, label: '法人' },{ value: 0, label: '非法人' }]
        }
      }
    },
    mounted() {
      this.$nextTick(() => {
        this.iscroll = new BScroll(this.$refs.scrollView, {
          click: true
        });
        this.iscroll2 = new BScroll(this.$refs.scrollView2, {
          click: true
        });
      })
      areaAddress().then(res => {
        if (res.data.errorCode === 0) {
          this.address = res.data.result
        } else {
          this.$weui.alert('地区数据加载失败，请刷新重试！')
        }
      })
      GetMerchantInfo(this.$route.query.merchant_num).then(res => {
        if (res.data.errorCode === 0) {
          this.$nextTick(() => {
            if (res.data.result.base.type == 300) {
              this.option = [{ value: 200, label: '对私' }]
            } else {
              this.option = [{ value: 200, label: '对私' },{ value: 100, label: '对公' }]
            }
          })
          res.data.result.bank.bank_account_type === 200 ? this.bank_account_type_name = '对私' : this.bank_account_type_name = '对公'
          res.data.result.bank.leader_type === 1 ? this.leader_type_name = '法人' : this.leader_type_name = '非法人'
          res.data.result.bank.bank_id_card_type === 1 ? this.bank_id_card_name = '身份证' : this.bank_id_card_name = ''
          this.merchant_type = res.data.result.base.type
          this.model.bank_account_name = res.data.result.bank.bank_account_name
          this.model.bank_account_type = res.data.result.bank.bank_account_type
          this.model.bank_account_no = res.data.result.bank.bank_account_no
          this.bank_name = res.data.result.bank.bank_name
          this.model.bank_code = res.data.result.bank.bank_name_code
          this.bank_branch_name = res.data.result.bank.bank_branch_name
          this.model.leader_type = res.data.result.bank.leader_type
          this.model.bank_branch_code = res.data.result.bank.bank_branch_code
          this.model.bank_address = res.data.result.bank.bank_address.code
          this.bank_address_name = res.data.result.bank.bank_address.name
          this.model.bank_pre_mobile = res.data.result.bank.bank_pre_mobile
          this.model.bank_id_card_expire = res.data.result.bank.bank_id_card_expire
          this.model.bank_id_card_addr = res.data.result.bank.bank_id_card_addr
          this.model.bank_id_card_no = res.data.result.bank.bank_id_card_no
          this.model.bank_id_card_type = res.data.result.bank.bank_id_card_type
          if (res.data.result.bank.photo.length !== 0) {
            res.data.result.bank.photo.hasOwnProperty('bank_permit') ? this.model.bank_permit = res.data.result.bank.photo.bank_permit[0] : this.model.bank_permit = ''
            res.data.result.bank.photo.hasOwnProperty('leader_id_3') ? this.model.leader_id_3 = res.data.result.bank.photo.leader_id_3[0] : this.model.leader_id_3 = ''
            res.data.result.bank.photo.hasOwnProperty('bank_card') ? this.model.bank_card = res.data.result.bank.photo.bank_card[0] : this.model.bank_card = ''
            res.data.result.bank.photo.hasOwnProperty('bank_idcard_2') ? this.model.leader_id_2 = res.data.result.bank.photo.bank_idcard_2[0] : this.model.leader_id_2 = ''
            res.data.result.bank.photo.hasOwnProperty('bank_idcard_1') ? this.model.leader_id_1 = res.data.result.bank.photo.bank_idcard_1[0] : this.model.leader_id_1 = ''
            res.data.result.bank.photo.hasOwnProperty('bank_card_inhand') ? this.model.bank_head = res.data.result.bank.photo.bank_card_inhand[0] : this.model.bank_head = ''
          }
        } else {
          this.$weui.alert(res.data.errorMsg)
        }
      })
    }
  }
</script>